/*
 * CodeSaveCommand.java
 *
 * Created on 2006년 3월 29일 (수), 오후 4:11
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.joinhawaii.admin.sales;

import java.io.File;
import java.util.*;




import javax.servlet.*;
import javax.servlet.http.*;

import com.zll.framework.conf.Configuration;
import com.zll.framework.model.HashBox;
import com.zll.framework.servlet.Command;
import com.joinhawaii.common.CommonUtil;





/**
 *
 * @author eastar
 */
public class VoucherSaveCommand implements Command
{

    public String execute(HttpServletRequest  request, HttpServletResponse response)
    throws Exception
    {
    	HashBox box = new HashBox(request);


    	//선택관광 외부바우처 파일
		File f = box.getFile("out_voucher_path");
		if (f != null) {
			File newFile = new File(Configuration.getHomePath() + "/home/voucher/out/" + box.get("est_no") + "_" + box.get("est_seq") + ".jpg");
			f.renameTo(newFile);
			box.put("out_voucher_path", "/home/voucher/out/" + newFile.getName());
		}


		SalesDAO dao 		= new SalesDAO();

		dao.updateVoucher(box);


		HashMap result		= new HashMap();
		result.put("result", 	"true");
		result.put("target",	box.target);
		result.put("action",	"/home/voucher/"+box.get("voucher_gubn")+"Voucher.jsp?est_no="+box.get("est_no")+"&est_seq="+box.get("est_seq"));

    	request.setAttribute("result", result);


    	return "/common/move_view.jsp";
    }
}
